# coding:utf-8
import redis
import time
from HELLO import HELLO
from zerocm import ZCM
import sys
sys.path.insert(0, './')

# redis 相关
host = sys.argv[1] if len(sys.argv) > 1 else '127.0.0.1'
port = sys.argv[2] if len(sys.argv) > 2 else '6379'
channel = sys.argv[3] if len(sys.argv) > 3 else 'TEST'
rc = redis.StrictRedis(host=host, port=port)
# zcm数据对象
send_msg = HELLO()
while True:
    # 准备消息
    send_msg.str = 'hello'
    send_msg.time = str(int(time.time()*1000))
    # 发布消息
    rc.publish(channel, send_msg.encode())
    print("send a message")
    time.sleep(5)
